<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <script type="text/javascript">  

              function objtakeMyValue(val,id) {  
                 // alert(val.value);
               document.getElementById("mainForm:DMObjectPropValueHidden").value=val.value;
               document.getElementById("mainForm:DMObjectPropValueIDHidden").value=id;
               objRemoteCMD1();
              }  
    </script> 

    <script type="text/javascript">

    </script>
    <h:inputHidden id="DMObjectPropValueHidden" value="#{generateWizardBean.updateDmObjPropTable.value}"/>
    <h:inputHidden id="DMObjectPropValueIDHidden" value="#{generateWizardBean.updateDmObjPropTable.ID}"/>

    <p:remoteCommand name="objRemoteCMD1" action="#{generateWizardBean.updateObjPropVal}" 
                     process="@this,DMObjectPropValueIDHidden,DMObjectPropValueHidden" update="list_growl,step3MSG"/>
    <p:messages id="step3MSG" showDetail="true" />


    <p:panel header="Objects">


        <h:panelGrid columns="2" columnClasses="label, value">



            <h:panelGrid columns="2" columnClasses="label, value">
                <h:selectOneListbox size="5"   id="dataModelObjects_IDTxt"
                                      value="#{generateWizardBean.selectedDataModelObjectTable.ID}"
                                      required="false"
                                      rendered="true"
                                      requiredMessage="dataModelProject is Mandatory" onchange="remoteCMDRefresh_obj();">
                    <f:selectItems value="#{generateWizardBean.dataModelObjectsList}" />
                </h:selectOneListbox>

            </h:panelGrid>
            <p:commandButton value="New" id="new_object" oncomplete="add_obj_dm_dialog.show()"/>
            <p:commandButton rendered="false" value="Edit" id="edit_object" oncomplete="varaddNewProjectDialog.show()"/>
            <p:remoteCommand name="remoteCMDRefresh_obj" action="#{generateWizardBean.refreshObjectsProperties}" process="@this, dataModelObjects_IDTxt" update="@this,dt1_obj"/>


        </h:panelGrid>


    </p:panel>


    <p:dataTable id="dt1_obj" var="info" value="#{generateWizardBean.dmObjPropTables}">

        <p:column>
            <f:facet name="header">
                <h:outputText value="Code" />
            </f:facet>
            <h:outputText  id="objPropCode_outputText" value="#{info.objPropCode}" />
                <p:tooltip for="objPropCode_outputText" value="#{info.objPropDescr}"
                           showEffect="slide" hideEffect="slide" 
                           showEffectLength="500" hideEffectLength="500"/>

        </p:column>
        <p:column>
            <f:facet name="header">
                <h:outputText value="Value" />
            </f:facet>
            <h:inputText style="width: 300px;" rendered="#{info.objPropType == 'inputtext'}" value="#{info.value}" id="objinputTxt12" onblur="objtakeMyValue(this,#{info.ID});" />
            <h:selectOneRadio rendered="#{info.objPropType == 'truefalse'}" value="#{info.value}" id="objinputRadioBx12" onchange="objtakeMyValue(this,#{info.ID});" >
                <f:selectItem itemLabel="true" itemValue="true"/>
                <f:selectItem itemLabel="false" itemValue="false"/>
            </h:selectOneRadio>
        </p:column>



    </p:dataTable>
    <p:remoteCommand name="showUpdateDialog_obj" oncomplete="varupdate_dm_Obj_prp_dialog.show()" process="@this" update="@this,update_dm_Obj_prp_dialog"/>
    <p:remoteCommand name="refreshDT_obj" process="@this"  update="dataModelObjects_IDTxt"/>




    <p:dialog id="add_Obj_dm_dialog"  header="Add New Data Model Object" widgetVar="add_obj_dm_dialog"
              modal="true" draggable="false" showEffect="fade" width="500" height="300" closeOnEscape="false">

        <table>

            <tr>
                <td>    <h:outputLabel rendered="true" value="Value" /></td>
            <td>:</td>
            <td>
            <h:inputText  id="ins_dataModelObject_Txt"
                          value="#{generateWizardBean.insertDataModelObjectTable.code}"
                          required="false"
                          rendered="true"
                          requiredMessage="Object Name is Mandatory"/>
            </td>
            </tr>


        </table>

        <h:panelGrid >
            <p:commandButton process="@this,ins_dataModelObject_Txt" update="dataModelObjects_IDTxt"
                             value="update" title="Update DmAttrProp" action="#{generateWizardBean.addNewDMObject}" oncomplete="add_obj_dm_dialog.hide();refreshDT_obj();"  />
        </h:panelGrid>
    </p:dialog>

</html>